Remove DBMap etc from XendDomainInfo, moving the handling of the domain root
authoremellor@ewan <emellor@ewan>
Tue, 27 Sep 2005 13:49:31 +0000 (14:49 +0100)
committeremellor@ewan <emellor@ewan>
Tue, 27 Sep 2005 13:49:31 +0000 (14:49 +0100)
and VM root totally into XendDomainInfo.  The DBMap stuff was all cruft,
following the move to xstransact.  Removing it may also help those suffering
from poor start-up times caused by a large store.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
tools/python/xen/xend/XendDomain.py
tools/python/xen/xend/XendDomainInfo.py

index 54faa6e33dae9425135243984a298bd34303d77b..57b127f153feea176e0b8fdd7792bc11fabfe7a9 100644 (file)
@@ -34,7 +34,6 @@ from xen.xend.XendError import XendError
 from xen.xend.XendLogging import log
 from xen.xend import scheduler
 from xen.xend.server import relocate
-from xen.xend.xenstore import XenNode, DBMap
 from xen.xend.xenstore.xstransact import xstransact
 
 
@@ -68,8 +67,6 @@ class XendDomain:
         # So we stuff the XendDomain instance (self) into xroot's components.
         xroot.add_component("xen.xend.XendDomain", self)
         self.domains = XendDomainDict()
-        self.vmroot = "/domain"
-        self.dbmap = DBMap(db=XenNode(self.vmroot))
         self.watchReleaseDomain()
         self.refresh()
         self.dom0_setup()
@@ -174,17 +171,6 @@ class XendDomain:
             if notify:
                 eserver.inject('xend.domain.died', [info.getName(),
                                                     info.getDomid()])
-        # XXX this should not be needed
-        for domdb in self.dbmap.values():
-            if not domdb.has_key("xend"):
-                continue
-            db = domdb.addChild("xend")
-            try:
-                domid = int(domdb["domid"].getData())
-            except:
-                domid = None
-            if (domid is None) or (domid == id):
-                domdb.delete()
 
 
     def refresh(self):
@@ -230,7 +216,7 @@ class XendDomain:
         @param config: configuration
         @return: domain
         """
-        dominfo = XendDomainInfo.create(self.dbmap.getPath(), config)
+        dominfo = XendDomainInfo.create(config)
         self._add_domain(dominfo)
         return dominfo
 
@@ -247,7 +233,7 @@ class XendDomain:
         nested = sxp.child_value(config, 'config')
         if nested:
             config = nested
-        return XendDomainInfo.restore(self.dbmap.getPath(), config)
+        return XendDomainInfo.restore(config)
 
     def domain_restore(self, src, progress=False):
         """Restore a domain from file.
index a3d6739bec940d2fd5bdfcf2c81fbafd2f472e01..e2148f9f9aebd4812577a2d7e916f426501b6333 100644 (file)
@@ -154,17 +154,16 @@ class XendDomainInfo:
     MINIMUM_RESTART_TIME = 20
 
 
-    def create(cls, dompath, config):
+    def create(cls, config):
         """Create a VM from a configuration.
 
-        @param dompath:   The path to all domain information
         @param config    configuration
         @raise: VmError for invalid configuration
         """
 
-        log.debug("XendDomainInfo.create(%s, ...)", dompath)
+        log.debug("XendDomainInfo.create(...)")
         
-        vm = cls(getUuid(), dompath, cls.parseConfig(config))
+        vm = cls(getUuid(), cls.parseConfig(config))
         vm.construct()
         vm.refreshShutdown()
         return vm
@@ -192,30 +191,27 @@ class XendDomainInfo:
                 raise XendError(
                     'No vm/uuid path in store for existing domain %d' % domid)
 
-            dompath = "/".join(dompath.split("/")[0:-1])
         except Exception, exn:
             log.warn(str(exn))
-            dompath = DOMROOT
             uuid = getUuid()
 
         log.info("Recreating domain %d, uuid %s", domid, uuid)
 
-        vm = cls(uuid, dompath, xeninfo, domid, True)
+        vm = cls(uuid, xeninfo, domid, True)
         vm.refreshShutdown(xeninfo)
         return vm
 
     recreate = classmethod(recreate)
 
 
-    def restore(cls, dompath, config, uuid = None):
+    def restore(cls, config, uuid = None):
         """Create a domain and a VM object to do a restore.
 
-        @param dompath:   The path to all domain information
         @param config:    domain configuration
         @param uuid:      uuid to use
         """
         
-        log.debug("XendDomainInfo.restore(%s, %s, %s)", dompath, config, uuid)
+        log.debug("XendDomainInfo.restore(%s, %s)", config, uuid)
 
         if not uuid:
             uuid = getUuid()
@@ -225,7 +221,7 @@ class XendDomainInfo:
         except TypeError, exn:
             raise VmError('Invalid ssidref in config: %s' % exn)
 
-        vm = cls(uuid, dompath, cls.parseConfig(config),
+        vm = cls(uuid, cls.parseConfig(config),
                  xc.domain_create(ssidref = ssidref))
         vm.create_channel()
         vm.configure()
@@ -293,12 +289,12 @@ class XendDomainInfo:
     parseConfig = classmethod(parseConfig)
 
     
-    def __init__(self, uuid, parentpath, info, domid = None, augment = False):
+    def __init__(self, uuid, info, domid = None, augment = False):
 
         self.uuid = uuid
         self.info = info
 
-        self.path = parentpath + "/" + uuid
+        self.path = DOMROOT + "/" + uuid
 
         if domid:
             self.domid = domid